﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="VipRegister.aspx.cs" Inherits="CL.UnionWeb.VipRegister" %>

<%@ Register Src="/ascx/TopMenu.ascx" TagPrefix="uc1" TagName="top" %>
<%@ Register Src="/ascx/LeftMenu.ascx" TagPrefix="uc2" TagName="left" %>


<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
      <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <title>推广联盟</title>
    <meta name="description" content="彩票" />
    <meta name="keywords" content="index" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="renderer" content="webkit" />
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <link rel="icon" type="image/png" href="/i/favicon.png" />
    <link rel="apple-touch-icon-precomposed" href="/i/app-icon72x72@2x.png" />
    <meta name="apple-mobile-web-app-title" content="推广联盟" />
    <link rel="stylesheet" href="/css/amazeui.min.css" />
    <link rel="stylesheet" href="/css/admin.css" />
    <link rel="stylesheet" href="/css/app.css" />
</head>
<body>
      <%--头部 S--%>
    <uc1:top runat="server" ID="top" />
    <%--头部 E--%>
    <div class="tpl-page-container tpl-page-header-fixed">
        <%--左边栏目列表 S--%>
        <uc2:left runat="server" id="left" activeid="6" />
        <%--左边栏目列表 E--%>
        <div class="tpl-content-wrapper">
            <div class="tpl-content-page-title">
                推广联盟系统
            </div>
            <ol class="am-breadcrumb">
                <li><a href="#" class="am-icon-home">首页</a></li>
                <li><a href="#">会员注册</a></li>
            </ol>
           <div class="tpl-portlet-components">
                <div class="portlet-title">
                    <div class="caption font-green bold">
                        <span class="am-icon-code"></span>会员注册
                    </div>
                    <div class="tpl-portlet-input tpl-fz-ml">
                        <div class="portlet-input input-small input-inline">
                            <div class="input-icon right">
                                <i class="am-icon-search"></i>
                                <input type="text" class="form-control form-control-solid" placeholder="搜索..." /> </div>
                        </div>
                    </div>
                </div>
                <div class="tpl-block ">

                    <div class="am-g tpl-amazeui-form">
                        <div class="am-u-sm-12 am-u-md-9">
                            <form class="am-form am-form-horizontal" id="form1"  <%--action="VipRegister.aspx"--%> onsubmit="return checkForm()">                                                          
                                <div class="am-form-group">
                                    <label for="user-phone" class="am-u-sm-3 am-form-label">手机号码/ Telephone</label>
                                    <div class="am-u-sm-9">
                                        <input type="tel" id="userphone" name="userphone" placeholder="输入你的手机号码 / Telephone" />
                                         <button type="button" id="getCheckCode" class="am-btn am-btn-primary">获取验证码</button>
                                          <small id="mobile">输入你的手机号码 </small>                                      
                                    </div>
                                </div>

                                 <div class="am-form-group">
                                    <label for="user-name" class="am-u-sm-3 am-form-label">验证码</label>
                                    <div class="am-u-sm-9">
                                        <input type="text" id="checkCode" name="checkCode" placeholder="验证码" />
                                        <small id="verfity">输入你的验证码</small>
                                    </div>
                                </div>

                                <div class="am-form-group">
                                    <label for="user-name" class="am-u-sm-3 am-form-label">密码</label>
                                    <div class="am-u-sm-9">
                                        <input type="password" id="userpwd"name="userpwd" placeholder="密码" />
                                        <small id="verfityPwd">输入你的密码</small>
                                    </div>
                                </div>
                              
                                <div class="am-form-group">
                                    <div class="am-u-sm-9 am-u-sm-push-3">
                                        <button type="submit" id="vipRegister" class="am-btn am-btn-primary">注册</button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>           
                <%--内容 E--%>
        </div>
    </div>
     <script src="/js/jquery.min.js"></script>
    <script src="/js/amazeui.min.js"></script>
    <script src="/js/iscroll.js"></script>
    <script src="/js/app.js"></script>
    <script type="text/javascript">
            //验证手机号
        $("#userphone").blur(function () {
            var phone = $("#userphone").val();
            var message = "";
            var myreg = /^(((13[0-9]{1})|(14[0-9]{1})|(17[0]{1})|(15[0-3]{1})|(15[5-9]{1})|(18[0-9]{1}))+\d{8})$/;
            if (phone == '') {
                message = "手机号码不能为空！";
                $("#mobile").text('').text(message);
                $("#userphone").focus();
            } else if (phone.length != 11) {
                message = "请输入有效的手机号码！";
                $("#mobile").text('').text(message);
                $("#userphone").focus();
            } else if (!myreg.test(phone)) {
                message = "请输入有效的手机号码！";
                $("#mobile").text('').text(message);
                $("#userphone").focus();
            } else {
                flag = true;
                $.get("/Register.ashx?action=IsMobileRegistered", { phone: phone }, function (data) {
                    alert(data);
                    if (data=="True") {
                        message = "该手机号码已经被绑定！";
                        $("#mobile").text('').text(message);
                        $("#userphone").focus();
                        return false;
                    }
                    $("#mobile").text('');
                    return true;
                });
            }           
        });
        $("#getCheckCode").click(function () {
            var phone = $("#userphone").val();
            $.ajax({
                type: 'get',
                dataType: 'text',
                url: '/Register.ashx?action=SendCheckCode&phone=' + phone,
                Async: true,
                data: {},
                success: function (result) {
                    alert(result);                   
                }
            })
        });

        $("#checkCode").blur(function () {
            var checkCode = $("#checkCode").val();
            if (checkCode == "") {
                $("#verfity").text('').text('验证码不能为空');
                $("#verfity").focus();
                return false;
            }
        });

        $("#userpwd").blur(function () {
            var userpwd = $("#userpwd").val();
            if (userpwd == "") {
                $("#verfityPwd").text('').text('密码不能为空');
                $("#verfityPwd").focus();
                return false;
            }
        });


        function checkForm() {
            var phone = $("#userphone").val();
            if (phone == '') {
                message = "手机号码不能为空！";
                $("#mobile").text('').text(message);
                $("#userphone").focus();
                return false;
            }
            var checkCode = $("#checkCode").val();
            if (checkCode == "") {
                $("#verfity").text('').text('验证码不能为空');
                $("#verfity").focus();
                return false ;
            }
            var userpwd = $("#userpwd").val();
            if (userpwd == "") {
                $("#verfityPwd").text('').text('密码不能为空');
                $("#verfityPwd").focus();
                return false;
            }
            return true;
        }

        $("#vipRegister").click(function () {
            if (checkForm()) {
                var data = $("#form1").serialize();
              var accountid=  window.location.href.split('=')[1];
                $.ajax({
                    type: 'post',
                    url: '/Register.ashx?action=UserRegister&' + data + '&accountid=' + accountid,
                    success: function (result) {
                        if (parseInt(result) > 0) {
                            var userCode = parseInt(result);
                            alert('注册成功!!');
                            window.location.href = "/union/BandUserInfo.aspx?userCode="+userCode;
                        }
                    }
                });
            }
        });


    </script>
</body>
</html>
